package com.tju.backend.utils.tool;


import cn.hutool.json.JSONObject;
import com.tju.backend.entity.OutWarehouseLog;
import com.tju.backend.entity.TStereoscopicWarehouse;
import com.tju.backend.entity.TWarehousing;

import java.util.List;

/**
 * 全局常量池
 *
 * @USER: CLS
 */
public class Constants {
    public static final String Authorization = "Authorization";//携带token参数
    public static final long EXPIRATION_TIME = 24 * 3600 * 1000; //Token过期时间单位：毫秒

    public static final String STRING = "STRING"; //字符串数标识
    public static final String CHARATER = "character,";//字符
    public static final String INTEGER = "Integer,";//无符号二进制，也就是整型
    public static final String MESSAGE_ONE = "00010000007F0110";//报文(功能码10写保持寄存器)
    public static final String NUMBER_LENGTH = "003C78";//寄存器的个数和长度
    public static final String MESSAGE_TWO = "0001000000060105";//报文(功能码05写单个线圈)

    public static Integer INTEGERCAPACITY(Integer number) {//长度两倍
        return number * 2;
    }

    public static final String CMSHL = "CMSHL"; //CMSHL
    public static final String AGV = "AGV"; //CMSHL

    public static final String GRID_INSIDE = "1"; //里面
    public static final String Pause = "Pause"; //暂停
    public static JSONObject json = new JSONObject();

    /**
     * 入仓数据赋值
     *
     * @param ware
     * @param total
     * @param num
     * @param surplus
     * @param swList
     * @return
     */
    public static JSONObject jsonObject(TWarehousing ware, int total, int num, int surplus, List<TStereoscopicWarehouse> swList) {
        json.clear();
        json.set("ware", ware);
        json.set("total", total);
        json.set("num", num);
        json.set("surplus", surplus);
        json.set("swList", swList);
        return json;
    }

    /**
     * 入仓日志封装
     *
     * @param wareLog
     * @param total
     * @param num
     * @param surplus
     * @return
     */
    public static JSONObject jsonObject(OutWarehouseLog wareLog, int total, int num, int surplus) {
        json.clear();
        json.set("wareLog", wareLog);
        json.set("total", total);
        json.set("num", num);
        json.set("surplus", surplus);
        return json;
    }
}
